package org.jeecg.modules.tankerRegistration.util;

/**
 * 距离计算工具类
 */
public class DistanceCalculator {
    private static final double EARTH_RADIUS = 6371393; // 地球平均半径（米）

    public static double calculate(double lng1, double lat1, double lng2, double lat2) {
        double radLat1 = Math.toRadians(lat1);
        double radLat2 = Math.toRadians(lat2);
        double a = radLat1 - radLat2;
        double b = Math.toRadians(lng1) - Math.toRadians(lng2);

        double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a/2),2) +
                Math.cos(radLat1)*Math.cos(radLat2)*Math.pow(Math.sin(b/2),2)));

        return s * EARTH_RADIUS;
    }
}
